﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Data;
using System.Data.Sql;
using System.Data.SqlClient;
using System.Windows.Forms;
using Microsoft.SqlServer.Management.Smo;
using Microsoft.SqlServer.Management.Nmo;
using Microsoft.SqlServer.Management.Common;
using Microsoft.SqlServer.Management.Trace;
using Entity;

namespace DataControls
{
    
    public class MONHOC_Data
    {
        DataBaseAccess dataBaseAccess = new DataBaseAccess();

        public void monhoc_Combobox(ComboBox cbMonHoc)
        {
            String excuteString = " SELECT * FROM MONHOC ";
            dataBaseAccess.addto_Combobox( cbMonHoc,excuteString);
        }

        public Boolean kiemtraMaMH_GiangDay(String mamonhoc)
        {
            int i = 0;
            String excuteString = "SELECT COUNT(*) FROM GIANGDAY WHERE MAMH='" + mamonhoc + "'";
            i = dataBaseAccess.Test(excuteString);
            if (i > 0)
                return true;
            else
                return false;
        }

        public Boolean kiemtra_MaMonHoc(String mamonhoc)
        {
            int i = 0;
            String excuteString = "SELECT COUNT(*) FROM MONHOC WHERE MAMH='" + mamonhoc + "'";
            i = dataBaseAccess.Test(excuteString);
            if (i > 0)
                return true;
            else
                return false;
        }

        public Boolean kiemtra_TenMonHoc(String tenmonhoc)
        {
            int i = 0;
            String excuteString = "SELECT COUNT(*) FROM MONHOC WHERE TENMH='" + tenmonhoc + "'";
            i = dataBaseAccess.Test(excuteString);
            if (i > 0)
                return true;
            else
                return false;
        }

        public float tinchi_lythuyet(String mamonhoc)
        {
            float a = 0;
            String excuteString = "SELECT TCLT FROM MONHOC WHERE MAMH='" + mamonhoc + "'";
            a = (float)Convert.ToDouble(dataBaseAccess.excuteScalar(excuteString));
            return a;
        }

        public float tinchi_thuchanh(String mamonhoc)
        {
            float a = 0;
            String excuteString = "SELECT TCTH FROM MONHOC WHERE MAMH='" + mamonhoc + "'";
            a = (float)Convert.ToDouble(dataBaseAccess.excuteScalar(excuteString));
            return a;
        }

    }
}
